<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='../vue.global.js'></script>
</head>

<body>
    <div id='app'>
        {{firstName}} · {{lastName}}
        <user-name v-model:first-name="firstName" v-model:last-name="lastName"></user-name>
    </div>

    <script>
        const app = Vue.createApp({
            data(){
                return {
                    firstName:"豹",
                    lastName:"西门"
                }
            }
        })

        app.component('user-name', {
            props: {
                firstName: String,
                lastName: String
            },
            emits: ['update:firstName', 'update:lastName'],
            template: `
                <input 
                type="text"
                :value="firstName"
                @input="$emit('update:firstName', $event.target.value)">

                <input
                type="text"
                :value="lastName"
                @input="$emit('update:lastName', $event.target.value)">
            `
        })

        app.mount('#app')
    </script>
</body>

</html>